/**
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var moveZeroes = function(nums) {
  let zeroCount = 0, index = 0;
  for(let i = 0; i < nums.length; i++) {
    if(nums[i] == 0)
      zeroCount++;
  }
  for(let i = 0; i < nums.length; i++) {
    if(nums[i] != 0) {
      nums[index++] = nums[i];
    }
  }
  for(let i = index; i < nums.length; i++) {
    nums[i] = 0;
  }
  return nums;
};

let nums = [0,1,0,3,12];
console.log(moveZeroes(nums));
nums = [0];
console.log(moveZeroes(nums));
